package com.yj.timecapsule.controller.message;

import com.yj.timecapsule.common.response.CommonResponseType;
import com.yj.timecapsule.entity.user.vo.MessageVo;
import com.yj.timecapsule.service.message.MessageService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Sean
 * @CreateTime 2024-08-03  22:26
 * @Description
 * @Version 1.0
 */
@RestController
@RequestMapping("/message")
public class MessageController {
    @Resource
    private MessageService messageService;
    @DeleteMapping("/clear-all")
    public CommonResponseType<Integer> clearAll(@RequestParam("targetId") Long targetId){
        Integer count = messageService.clearAll(targetId);
        return CommonResponseType.success(count);
    }
    @DeleteMapping("/del")
    public CommonResponseType<Object> del(@RequestParam("messageIds")List<Long> ids){
        messageService.del(ids);
        return CommonResponseType.success();
    }
    @GetMapping("/get-messages")
    public CommonResponseType<List<MessageVo>> getMessages(@RequestParam("targetId") Long targetId){
        List<MessageVo> messageVoList = messageService.getMessages(targetId);
        return CommonResponseType.success(messageVoList);
    }
}
